package com.xiweicheng.test.delay_task;

import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.util.concurrent.TimeUnit;

public class RedissonMain {

    public static void main(String[] args) throws InterruptedException {

        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
//        config.useSingleServer().setPassword("redis1234");

        final RedissonClient client = Redisson.create(config);
        RLock lock = client.getLock("lock1");

        try {
//            lock.lock();
            lock.lock(10, TimeUnit.SECONDS);
            Thread.sleep(1000 * 60 * 10);
        } finally {
            lock.unlock();
        }
    }
}
